#include <time.h>
#include <unistd.h>
#include "threadpool.hpp"
#include "task.hpp"
#include "log.hpp"

int main()
{
    srand((unsigned int)time(nullptr) ^ getpid());

    threadPool<Task> *pool = new threadPool<Task>();
    logMessage(DEBUG, "成功创建线程池");

    pool->run();
    logMessage(DEBUG, "成功运行线程池");

    while (true)
    {
        int x = rand() % 100 + 1;
        usleep(2333);
        int y = rand() % 100 + 1;
        Task t(x, y, [](int x, int y) -> int
               { return x + y; });
        logMessage(DEBUG, "成功制作任务--- add: %d, %d", t._x, t._y);

        pool->pushTask(t);
        sleep(1);
    }
    return 0;
}
